<?php

/**
 *  后台管理程序
 * --------------------------------------------------------
 * @copyright  http://lin.97md.net
 * @access       MyDream
 * @author      zxing@97md.net
 * $Id: login.php 25 2011-12-06 07:39:17Z zx860106@gmail.com $
 * $Date: 2011-12-06 15:39:17 +0800 (星期二, 06 十二月 2011) $
 * --------------------------------------------------------
 * @example
 *
 */
require dirname(dirname(__FILE__)) . '/include/init.php';
require model('login');
require model('admin');

//判断是否登录
is_login();
$action = $_GET['action'];
if (empty($_SESSION['id'])) {
    show_msg('您还没有登录，请先登录', '/admin/login.php');
} elseif ($action == 'admin') {
    include WEB_ROOT . '/admin/template/admin.html.php';
} elseif ($action == 'showinfo') {
    $webinfos=get_webinfo();//获取网站的相关信息
    include WEB_ROOT . '/admin/template/menu_systerminfo.html.php';
} elseif ($action == 'add') {//输入网站标题和备案号
    $url = 'admin.php?action=doadd';
    include WEB_ROOT . '/admin/template/menu_editwebinfo.html.php';
} elseif ($action == 'doadd') {//对提交的信息进行处理
    if (isset($_POST["submit"])) {
        add_webinfo($_POST['webtitle'], $_POST['webno']);
    }
} elseif ($action == 'default') {//查看网站标题和备案号
    $webInfo = show_webinfo();
    $webTitle = $webInfo[1];
    $webNo = $webInfo[0];
    $url = 'admin.php?action=edit'; //修改网站信息的url
    include WEB_ROOT . '/admin/template/menu_webinfo.html.php';
} elseif ($action == 'edit') {//修改网站标题和备案号
    $webInfo = show_webinfo();
    $webTitle = $webInfo[1];
    $webNo = $webInfo[0];
    $url = 'admin.php?action=doedit';
    include WEB_ROOT . '/admin/template/menu_editwebinfo.html.php';
} elseif ($action == 'doedit') {//处理修改的网站信息
    if (isset($_POST["submit"])) {
        edit_webinfo($_POST['webtitle'], $_POST['webno']);
    }
}
